<?php

namespace common\models\kingdee;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\kingdee\HrEmpLaborRelation;

/**
 * HrEmpLaborRelationSearch represents the model behind the search form about `common\models\kingdee\HrEmpLaborRelation`.
 */
class HrEmpLaborRelationSearch extends HrEmpLaborRelation
{
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['FEFFDT', 'FLEFFDT', 'FHISTORYRELATEID', 'FCORPORATEUNITID', 'FLABORRELATIONSTATEID', 'FFLOWINAFFAIRID', 'FPERSONID', 'FCREATORID', 'FCREATETIME', 'FLASTUPDATEUSERID', 'FLASTUPDATETIME', 'FCONTROLUNITID', 'FID', 'FEMPLOYEEMODLEID'], 'safe'],
            [['FLABORRELATIONTYPE'], 'integer'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function scenarios()
    {
        // bypass scenarios() implementation in the parent class
        return Model::scenarios();
    }

    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
        $query = HrEmpLaborRelation::find();

        // add conditions that should always apply here

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        // grid filtering conditions
        $query->andFilterWhere([
            'FEFFDT' => $this->FEFFDT,
            'FLEFFDT' => $this->FLEFFDT,
            'FLABORRELATIONTYPE' => $this->FLABORRELATIONTYPE,
            'FCREATETIME' => $this->FCREATETIME,
            'FLASTUPDATETIME' => $this->FLASTUPDATETIME,
        ]);

        $query->andFilterWhere(['like', 'FHISTORYRELATEID', $this->FHISTORYRELATEID])
            ->andFilterWhere(['like', 'FCORPORATEUNITID', $this->FCORPORATEUNITID])
            ->andFilterWhere(['like', 'FLABORRELATIONSTATEID', $this->FLABORRELATIONSTATEID])
            ->andFilterWhere(['like', 'FFLOWINAFFAIRID', $this->FFLOWINAFFAIRID])
            ->andFilterWhere(['like', 'FPERSONID', $this->FPERSONID])
            ->andFilterWhere(['like', 'FCREATORID', $this->FCREATORID])
            ->andFilterWhere(['like', 'FLASTUPDATEUSERID', $this->FLASTUPDATEUSERID])
            ->andFilterWhere(['like', 'FCONTROLUNITID', $this->FCONTROLUNITID])
            ->andFilterWhere(['like', 'FID', $this->FID])
            ->andFilterWhere(['like', 'FEMPLOYEEMODLEID', $this->FEMPLOYEEMODLEID]);

        return $dataProvider;
    }
}
